export default function useFindAccount (data) {
const accountNumbers: any = {}
const showData = {};
function handleItem(key: string, item: any, keyIndex: number) {
  const key2 = key.replace('_list', '')
  data[key].forEach((item2: any) => {
    if (item.PDAID == item2.PDAID) {
      const index = accountNumbers[item.PD01AD01]
      if (keyIndex == 0) {
        showData[item.PD01AD01][index] = {
          [key2]: item2,
          pc_cr_tr: item
        }
      } else {
        const dataObj = showData[item.PD01AD01][index];
        if(key === 'pc_pda_pd_e_list'){
          //该字段为列表
          if(typeof dataObj[key2] == 'object'){
            dataObj[key2].push(item2)
          }else{
            dataObj[key2] = [item2]
          }
        }else{
          //其他为对象
          dataObj[key2] = item2
        }
      }

    }
  })
}
  const basic = data.pc_cr_tr_list
  for (let i = 0; i < basic.length; i++) {
    const item = basic[i];
    accountNumbers[item.PD01AD01] = accountNumbers[item.PD01AD01] ?? 0;
    showData[item.PD01AD01] = showData[item.PD01AD01] || [];
    (['pc_pda_pd_b_list', 'pc_pda_pd_c_list', 'pc_pda_pd_e_list', 'pc_pda_pd_h_list'])
      .forEach((key, keyIndex) => handleItem(key, item, keyIndex));
    accountNumbers[item.PD01AD01]++
    // pc_pda_pd_b_list 最新表现信息
    // pc_pda_pd_c_list 最近一次月度表现信息
    // pc_pda_pd_e_list  最近 5 年内历史表现信息 
    // pc_pda_pd_h_list 借贷账户大额专项分期信息
  }

  console.log('showdata', showData)
  return showData

}